﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Init {
    import flash.events.*;
    import Engine.Init.*;
    import Classes.*;
    import validation.*;
    import scripting.*;
    import Classes.announcements.*;
    import Modules.crew.*;
    import Modules.zoo.*;
    import Modules.franchise.*;
    import Modules.flashsale.*;
    import Modules.freegiftsale.*;

    public class GlobalsInit extends InitializationAction {

        public static const INIT_ID:String = "GlobalsInit";

        public function GlobalsInit(){
            super(INIT_ID);
            addDependency(SocialNetworkInit.INIT_ID);
        }
        override public function execute():void{
            Global.player = new Player((GlobalEngine.socialNetwork) ? GlobalEngine.socialNetwork.getLoggedInUser() : null);
            Global.flashSaleManager = new FlashSaleManager();
            Global.freeGiftSaleManager = new FreeGiftSaleManager();
            Global.scriptingManager = new ScriptingManager();
            Global.validationManager = new ValidationManager();
            Global.announcementManager = new AnnouncementManager();
            Global.franchiseManager = new FranchiseManager();
            Global.zooManager = new ZooManager();
            Global.rollCallManager = new RollCallManager();
            Global.crews = new CrewMap();
            if (GlobalEngine.socialNetwork){
                Global.player.setFriends(GlobalEngine.socialNetwork.getFriendUsers());
                Global.player.appFriends = GlobalEngine.socialNetwork.getAppFriendsIds();
            };
            Global.world = new GameWorld();
            Global.world.addEventListener(Event.COMPLETE, this.onGameWorldInitialized);
            Global.world.initialize();
        }
        protected function onGameWorldInitialized(_arg1:Event):void{
            Global.world.removeEventListener(Event.COMPLETE, this.onGameWorldInitialized);
            dispatchEvent(new Event(Event.COMPLETE));
        }

    }
}//package Init 
